<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    #box{
        width: 500px;
        height: 200px;
        background-color: aqua;
        margin: auto;
        margin-top: 250px;
        display: none;
    }
    .box1{
        width: 100%;
        height: 40px;
        background-color: blue;
    }
    .box2{
        float: right;
        margin: 10px;
        /* display: block; */
    }
</style>
<body>
    <button onclick="goto()">弹出层</button>
    <div id="box">
        <div class="box1">
            <span class="box2" onclick="xxx()">X</span>
        </div>
    </div>
</body>
<script>
    function goto(){
        var x=document.getElementById('box').style.display="block"
    }
    function xxx(){
        var x=document.getElementById('box').style.display="none"
    }
</script>
</html>